package cn.yuyiling.jelly.sr.controller;

import cn.yuyiling.jelly.kg.mongodb.entity.KnowledgePoint;
import cn.yuyiling.jelly.qa.dto.AnswerDTO;
import cn.yuyiling.jelly.qa.mapper.AnswerMapper;
import cn.yuyiling.jelly.qa.mongodb.entity.Answer;
import cn.yuyiling.jelly.sr.api.RankService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/rank")
public class RankController {
    @DubboReference(scope = "remote")
    private RankService rankService;

    @GetMapping("/weekly/top/{count}")
    public List<String> getWeeklyTopUsers(@PathVariable Integer count) {
        return rankService.getWeeklyTopUsers(count);
    }

    /**
     * 每周一凌晨清空上一周排行榜数据
     */
    @Scheduled(cron = "0 0 0 * * MON")
    public void resetWeeklyRanking() {
        rankService.resetWeeklyRanking();
    }

}
